package com.work.vo.main;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.work.utils.BigDecimalSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springblade.core.tool.utils.Func;

import java.math.BigDecimal;

/**
 * 退关总量VO
 *
 * @author ：dujianyu
 * @since ：Created in 2024/5/28 13:57
 */
@Data
public class RetreatTotalVO {

    /** 总船数 */
    @ApiModelProperty(name = "总船数",notes = "")
    private Integer ships ;

    /** allRetreatPiece */
    @ApiModelProperty(name = "总退关件数",notes = "")
    private Integer allRetreatPiece ;

    /** 总退关吨数 */
    @JsonSerialize(using = BigDecimalSerializer.class)
    @ApiModelProperty(name = "总退关吨数",notes = "")
    private BigDecimal allRetreatTon ;

    /** 总提货件数 */
    @ApiModelProperty(name = "总提货件数",notes = "")
    private Integer allOutPiece ;

    /** 总提货吨数 */
    @JsonSerialize(using = BigDecimalSerializer.class)
    @ApiModelProperty(name = "总提货吨数",notes = "")
    private BigDecimal allOutTon ;

    /** 总结余件数 */
    @ApiModelProperty(name = "总结余件数",notes = "")
    private Integer allLeftPiece ;

    /** 总结余吨数 */
    @JsonSerialize(using = BigDecimalSerializer.class)
    @ApiModelProperty(name = "总结余吨数",notes = "")
    private BigDecimal allLeftTon ;

    public Integer getAllLeftPiece() {
        if (Func.isNull(allRetreatPiece) || Func.isNull(allOutPiece)) {
            return null;
        }
        return allRetreatPiece - allOutPiece;
    }

    public BigDecimal getAllLeftTon() {
        if (Func.isNull(allRetreatTon) || Func.isNull(allOutTon)) {
            return null;
        }
        return allRetreatTon.subtract(allOutTon);
    }

}
